package org.zfes.snowier.zbss.xzy.router.user.message;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.message.model.MessageType;
import org.zfes.snowier.zbss.xzy.biz.message.service.IMessageTypeService;
import org.zfes.snowier.core.data.SelectVo;
@Controller("org.zfes.snowier.zbss.xzy.router.user.message.MessageTypeController") 
@RequestMapping("/api/user/message")
public class MessageTypeController implements BaseController {

	
	@Autowired
	private IMessageTypeService messageTypeService;
	
    @RequestMapping(value="/loadMessageTypeDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadMessageTypeDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  messageTypeService.loadMessageTypeDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/createMessageType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createMessageType(@RequestBody MessageType messageType){
		messageTypeService.createMessageType(messageType);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadMessageType/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadMessageType(@PathVariable("id")Long id){
		Optional<MessageType> ops = messageTypeService.loadMessageTypeById(id);
		return ajaxQuery("messageType",ops);
    }
	
    @RequestMapping(value="/updateMessageType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateMessageType(@RequestBody  MessageType messageType){
		messageTypeService.updateMessageType(messageType);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/deleteMessageType/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteMessageType(@PathVariable("id")Long id){
		messageTypeService.setMessageTypeStatus(id, Byte.valueOf("2"));
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadMessageTypeSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadMessageTypeSelectVo(){
		 List<SelectVo>  ops = messageTypeService.loadMessageTypeSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}